<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>初始页面</h1>
    <!-- 订单号在这里是固定了，其实后端方便测试做了一个雪花算法的id -->
            <button onclick="cona()">支付宝 - 立即支付</button>
    <button onclick="conas()">取消支付</button>
</body>

<script type="text/javascript">
    var a=GetRequest();



    console.log("id:"+a['id']) //打印出传过来的id
    function conas() {
        $.ajax({
            url : "http://localhost:7009/update",//请求地址
            data:{id:a['id']},
            dataType : "json",//数据格式
            type : "post",//请求方式
            async : false,//是否异步请求
            success : function(data) { //如何发送成功
                window.location.href="http://localhost/resource/plans";
            }
        });



    }

function cona() {
        window.location.href="http://localhost:7009/payOrder?id="+a['id'];
}
    function GetRequest() {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
</script>

</html>